<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <style>
        div {
            width: 100px;
            height: 100px;
            background-color: antiquewhite;
        }
    </style>
</head>

<body>

    <div></div>


</body>

<script>
    //style只能获取行内样式 无法获取行外样式
    //offset就可以
    var div = document.getElementsByTagName('div');
    console.log(div[0].style.width);
    console.log(div[0].offsetWidth);
</script>

</html>